import sys
from random import choice, randint

from PySide6.QtCore import Qt
from PySide6.QtGui import QPen, QPainter, QPixmap, QColor
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.label = QLabel()
        self.canvas = QPixmap(400, 300)
        self.canvas.fill(Qt.white)

        self.setCentralWidget(self.label)
        self.draw_something2()

    def draw_something(self):
        painter = QPainter(self.canvas)
        pen = QPen()
        pen.setWidth(3)
        painter.setPen(pen)

        for n in range(10000):
            painter.drawPoint(200 + randint(-100, 100), 150 + randint(-100, 100))

        painter.end()
        self.label.setPixmap(self.canvas)

    def draw_something2(self):
        colors = ['#FFD141', '#FFB800', '#FF8C00', '#FF4E00', '#FF0000', '#CC0033', '#990033', '#660033', '#330033', '#000033']

        painter = QPainter(self.canvas)
        pen = QPen()
        pen.setWidth(3)
        painter.setPen(pen)

        for n in range(10000):
            color = choice(colors)
            pen.setColor(QColor(color))
            painter.setPen(pen)
            painter.drawPoint(200 + randint(-100, 100), 150 + randint(-100, 100))

        painter.end()
        self.label.setPixmap(self.canvas)


if __name__ == "__main__":
    app = QApplication(sys.argv)

    window = MainWindow()
    window.show()

    sys.exit(app.exec())
